﻿using System.ServiceModel;
using Framework.Remoting.Client;
using Rhino.Mocks;
using Xunit;

namespace Framework.Tests.Wcf.Client
{
    public class ChannelPerRequestManagerTest : ManagedChannelManagerTestBase<ChannelPerRequest>
    {
        [Fact]
        public void When_state_is_not_faulted_or_closed_Then_Close()
        {
            ChannelContractMock.Expect(x => x.State).Return(CommunicationState.Opened).Repeat.Any();
            ChannelContractMock.Expect(x => x.Close());
            MockRepository.ReplayAll();
            Target.EndRequest(ChannelContractMock);
            MockRepository.VerifyAll();
        }

        [Fact]
        public void Do_nothing_when_dispose()
        {
            MockRepository.ReplayAll();
            Target.Dispose();
            MockRepository.VerifyAll();
        }
    }
}